<template>
  <div class="profile-page">
    <TopNav title="个人中心"/>

    <main class="main-content">
      <!-- 用户信息 -->
      <section class="user-info">
        <div class="avatar">
          <img :src="userInfo.avatar" :alt="userInfo.name"/>
        </div>
        <div class="user-details">
          <h2 class="user-name">{{ userInfo.name }}</h2>
          <p class="user-bio">{{ userInfo.bio }}</p>
        </div>
      </section>

      <!-- 统计信息 -->
      <section class="stats">
        <div class="stat-item">
          <div class="stat-number">{{ userInfo.recipeCount }}</div>
          <div class="stat-label">我的食谱</div>
        </div>
        <div class="stat-item">
          <div class="stat-number">{{ userInfo.favoriteCount }}</div>
          <div class="stat-label">收藏</div>
        </div>
        <div class="stat-item">
          <div class="stat-number">{{ userInfo.followersCount }}</div>
          <div class="stat-label">粉丝</div>
        </div>
      </section>

      <!-- 功能菜单 -->
      <section class="menu-section">
        <div class="menu-item" @click="handleEditProfile">
          <User class="menu-icon"/>
          <span class="menu-text">编辑资料</span>
          <ChevronRight class="menu-arrow"/>
        </div>
        <div class="menu-item" @click="handleMyRecipes">
          <BookOpen class="menu-icon"/>
          <span class="menu-text">我的食谱</span>
          <ChevronRight class="menu-arrow"/>
        </div>
        <div class="menu-item" @click="handleSettings">
          <Settings class="menu-icon"/>
          <span class="menu-text">设置</span>
          <ChevronRight class="menu-arrow"/>
        </div>
        <div class="menu-item" @click="handleAbout">
          <Info class="menu-icon"/>
          <span class="menu-text">关于我们</span>
          <ChevronRight class="menu-arrow"/>
        </div>
      </section>
    </main>
  </div>
</template>

<script setup lang="ts">
import {ref} from 'vue'
import {BookOpen, ChevronRight, Info, Settings, User} from 'lucide-vue-next'
import TopNav from "@/components/TopNav.vue";

interface UserInfo {
  name: string
  bio: string
  avatar: string
  recipeCount: number
  favoriteCount: number
  followersCount: number
}

const userInfo = ref<UserInfo>({
  name: '美食爱好者',
  bio: '热爱烹饪，分享美味',
  avatar: 'https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=150',
  recipeCount: 12,
  favoriteCount: 28,
  followersCount: 156
})

const handleEditProfile = () => {
  console.log('编辑资料')
}

const handleMyRecipes = () => {
  console.log('我的食谱')
}

const handleSettings = () => {
  console.log('设置')
}

const handleAbout = () => {
  console.log('关于我们')
}
</script>

<style lang="scss" scoped>
.profile-page {
  min-height: 100vh;
  background-color: var(--color-background);
}

.main-content {
  padding: var(--spacing-md);
  max-width: 1200px;
  margin: 0 auto;
}

.user-info {
  display: flex;
  align-items: center;
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
}

.avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  margin-right: var(--spacing-md);

  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

.user-details {
  flex: 1;
}

.user-name {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--spacing-xs);
}

.user-bio {
  color: var(--color-text-light);
  font-size: var(--font-size-sm);
}

.stats {
  display: flex;
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
}

.stat-item {
  flex: 1;
  text-align: center;

  &:not(:last-child) {
    border-right: 1px solid var(--color-border);
  }
}

.stat-number {
  font-size: var(--font-size-xxl);
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: var(--spacing-xs);
}

.stat-label {
  color: var(--color-text-light);
  font-size: var(--font-size-sm);
}

.menu-section {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.menu-item {
  display: flex;
  align-items: center;
  padding: var(--spacing-md) var(--spacing-lg);
  cursor: pointer;
  transition: background-color 0.3s ease;

  &:not(:last-child) {
    border-bottom: 1px solid var(--color-border);
  }

  &:hover {
    background-color: var(--color-background);
  }
}

.menu-icon {
  width: 20px;
  height: 20px;
  color: var(--color-primary);
  margin-right: var(--spacing-md);
}

.menu-text {
  flex: 1;
  color: var(--color-text);
  font-size: var(--font-size-md);
}

.menu-arrow {
  width: 16px;
  height: 16px;
  color: var(--color-text-light);
}

@media (max-width: 768px) {
  .user-info {
    flex-direction: column;
    text-align: center;

    .avatar {
      margin-right: 0;
      margin-bottom: var(--spacing-md);
    }
  }

  .stats {
    flex-direction: column;
    gap: var(--spacing-md);

    .stat-item:not(:last-child) {
      border-right: none;
      border-bottom: 1px solid var(--color-border);
      padding-bottom: var(--spacing-md);
    }
  }
}
</style>
